<template>
  <section>
    <!--顶部导航条 -->
    <div class="am-container header">
      <ul class="message-l">
        <div v-if="!isLogin" class="topMessage">
          <div class="menu-hd">
            <a href="login.html"
                target="_top"
                class="h">请登录</a>
            <a href="login.html#/register"
                target="_top">注册</a>
          </div>
        </div>
      </ul>
      <ul class="message-r">
        <div class="topMessage home">
          <div class="menu-hd">
            <a href=""
                target="_top"
                class="h">商城首页</a></div>
        </div>
        <div class="topMessage my-shangcheng">
          <div class="menu-hd MyShangcheng">
            <a href="user.html"
                target="_blank"><i class="am-icon-user am-icon-fw"></i>个人中心</a></div>
        </div>
        <div class="topMessage mini-cart">
          <div class="menu-hd">
            <a id="mc-menu-hd"
                href="#"
                target="_top">
              <i class="am-icon-shopping-cart  am-icon-fw"></i><span>购物车</span><strong id="J_MiniCartNum"
                      class="h">0</strong>
            </a>
          </div>
        </div>
        <div class="topMessage favorite">
          <div class="menu-hd"><a href="#"
                target="_top"><i class="am-icon-heart am-icon-fw"></i><span>收藏夹</span></a></div>
        </div>
      </ul>
    </div>

    <!--悬浮搜索框-->
    <div class="nav white">
      <div class="logo"><img src="static/images/logo.png"></div>
      <div class="logoBig">
        <li class=""><img src="static/images/logobig.png"></li>
      </div>

      <div class="search-bar pr">
        <a name="index_none_header_sysc"
            href="#"></a>
        <form onsubmit="return false;">
          <input id="searchInput"
                  name="index_none_header_sysc"
                  type="text"
                  placeholder="搜索"
                  autocomplete="off"
                  v-model="searchKey">
          <input id="ai-topsearch"
                  class="submit am-btn"
                  value="搜索"
                  index="1"
                  type="submit"
                  @click="search">
        </form>
      </div>
    </div>

    <div class="clear"></div>
  </section>
</template>

<script>

import { mapGetters } from 'vuex'

export default {
  name: 'YYHeader',
  data () {
    return {
      searchKey: ''
    }
  },
  methods: {
    search () {
      let url = `/search.html?keyword=${this.searchKey}`
      window.location.href = url
    }
  },
  computed: {
    ...mapGetters({
      isLogin: 'isLogin',
      userInfo: 'getUserInfo'
    })
  }
}
</script>
